<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="productCategoryTag"/>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
			<button class="btn btn-primary btn-outline" onclick="add();">新增</button>
			<p></p>
	<table id="table" data-toggle="table" data-height="400" data-click-to-select="true" data-mobile-responsive="true">
                                    <thead>
                                        <tr>
                                            <th data-field="name">标签名</th>
                                            <th data-field="value">标签值</th>
                                            <th></th>
                                        </tr>
                                    </thead>
							<tbody>
								<c:forEach items="${tags }" var="n" varStatus="idx">
								<tr data-index="${idx.index }">
									<td>${n.name }</td>
									<td>${n.values }</td>
									<td>
										<button class="btn btn-primary btn-outline" onclick="edit('${n.id}')">修改</button>
										<button class="btn btn-primary btn-danger" onclick="del('${n.id}')">删除</button>
									</td>
								</tr>
								</c:forEach>
							</tbody>
	</table>
</div>

<%@include file="/common/foot.jsp" %>

<script>
function add() {
	layer.open({
	    type: 2,
	    skin: 'layui-layer-rim', //加上边框
	    area: [layer_default_width, layer_default_height], //宽高
	    content: "${ctx}/admin/productCategoryTag/edit?productCategoryId=${productCategoryId}",
	    btn: ['确定', '取消'],
	    yes: function(index, layero){ //或者使用btn1
	    	var detailForm = layer.getChildFrame('form', index);
	    	console.log(detailForm);
	    	detailForm.ajaxSubmit({
	    		success: function(data) {
	    			if (isSuccess(data)) {
	    				layer.close(index);
	    				reload2();
	    			} else {
	    			}
	    		}
	    	});
	    }, cancel: function(index){ //或者使用btn2
	        //按钮【按钮二】的回调
	    }
	});
}

function edit(id) {
	layer.open({
	    type: 2,
	    skin: 'layui-layer-rim', //加上边框
	    area: [layer_default_width, layer_default_height], //宽高
	    content: "${ctx}/admin/productCategoryTag/edit?id=" + id + "&productCategoryId=${productCategoryId}",
	    btn: ['确定', '取消'],
	    yes: function(index, layero){ //或者使用btn1
	    	var detailForm = layer.getChildFrame('form', index);
	    	console.log(detailForm);
	    	detailForm.ajaxSubmit({
	    		success: function(data) {
	    			if (isSuccess(data)) {
	    				layer.close(index);
	    				reload2();
	    			} else {
	    			}
	    		}
	    	});
	    }, cancel: function(index){ //或者使用btn2
	        //按钮【按钮二】的回调
	    }
	});
}


function del(id) {
	layer.confirm('确认要删除吗?', {icon: 3, title:'提示'}, function(index){
		$.ajax({
			url: "${ctx}/admin/productCategoryTag/delete",
			data: {
				ids: id
			},
			success: function(data) {
				if (isSuccess(data)) {
					layer.close(index);
					reload2();
				}
			}
		});
	});
	
}
</script>

</body>
</html>
